package com.example.iot.util;


import lombok.AllArgsConstructor;
import lombok.Data;




@Data
//数据工具类
@AllArgsConstructor
public class R {
    private  Boolean flag;//请求状态
    private  String msg;//响应消息
    private Object data;//数据载体
    private  Integer code;//状态码
    public R(Boolean flag)
    {
        this.flag=flag;
    }
    public R() {}


    public R(Object data) {
        this.data=data;
    }

    public static R ok (Object data){
        R r = new R(data);
        r.setCode(200);
        r.setFlag(true);
        return r;
    }
    public static R fail (Object data){
        R r = new R(data);
        r.setCode(500);
        r.setFlag(false);
        return r;
    }
}
